package com.erlang4j.internal.basicIo;

import com.ericsson.otp.erlang.OtpErlangObject;
import com.ericsson.otp.erlang.OtpErlangPid;

/**
 * These are the basic operations required by a mail box. Design Notes:<be>
 * <ul>
 * <li>This is effectively allowing us to implement a "mixin" in java: the MailBox delegates to this.
 * <li>Mocking is now a lot easier
 * <li>When connecting to a local or remote node using JInterface we need OtpNode or OtpSelf and the interactions with
 * the two are very different. This allows us to hide that
 * </ul>
 */
public interface IBasicMailBox {

	/**
	 * Send this object to either the registered serverName or the pid. Throws exception if not a string or an
	 * OtpErlangPid
	 */
	void send(Object serverNameOrPid, OtpErlangObject object);

	/** receive, but return null if timeouts */
	OtpErlangObject receive(long timeout);

	/**
	 * if there is an item in the mailbox return it. If not, wait until there is
	 */
	OtpErlangObject receive();

	/** the pid of this mail box */
	OtpErlangPid self();

}
